/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import java.sql.*;
import DTO.NguoiDung_DTO;
import java.util.ArrayList;

/**
 *
 * @author phihai
 */
public class Login_DAO {
    
    Database db = new Database();
    Connection conn = null;
    PreparedStatement pst = null;
    
    public int Login(String user , String pass) throws Exception
    {      
        String sql = "SELECT * FROM NguoiDung WHERE UserName = '"+user+"' AND MatKhau = '"+pass+"'";      
        conn = db.open();
        pst = conn.prepareStatement(sql);
        int tmp = -1; 
        ResultSet rs = pst.executeQuery();
        while (rs.next())
        {
            tmp = rs.getInt("LoaiND");
        }
        db.close();
        return tmp;
    }
}
